<template>
  <div class="container">
    <nav-bar :title="$route.meta.title" />
    <div v-if="lsitData.length>0" class="content">
      <div class="tit">订单列表</div>
      <van-list
        v-model="loading"
        :finished="finished"
        finished-text="没有更多了"
        @load="onLoad"
      >
        <div class="list">
          <div v-for="(item,index) in lsitData" :key="'zhi'+index" class="li">
            <div class="top">
              <span class="types">订单编号：</span>
              <span>【{{ item.id }}】</span>
            </div>
            <div class="contents">
              <div class="left">
                <img class="userAvator" :src="item.payImgUrl" alt="">

              </div>
              <div class="right">
                <div class="truename">{{ item.name }}</div>
                <!-- <div class="tags">
                  <span>买方：{{ item.buyUserName }}</span>
                  <span>卖方：{{ item.saleUserName }}</span>
                </div> -->
                <div class="bots">
                  <div>￥{{ item.orderPrice }}</div>
                <!-- <div>X{{ item.count }}</div> -->
                </div>
              </div>
            </div>
            <div class="time">{{ item.orderTime }}</div>
          </div>
        </div>
      </van-list>
    </div>
    <van-empty v-else description="暂无数据" />
  </div>
</template>
<script>
import { getFansOrderList } from '@/api/fans'
export default {
  name: 'Detail',
  data() {
    return {
      lsitData: [
      ],
      loading: true,
      finished: false,
      page: 1
    }
  },

  async created() {
    await this.init()
  },
  methods: {
    async init() {
      const res = await getFansOrderList({ pageNum: this.page })
      console.log(res)
      const records = res.map.page?.records || []
      records.forEach(item => {
        console.log(item.orderTime)
        const times = new Date(item.orderTime).toLocaleString({ hour12: false }, 'yyyy-MM-dd hh:mm:ss')
        console.log('times==', times)
        item.orderTime = times
      })
      if (this.page == 1) {
        this.lsitData = records
      } else {
        records.forEach(item => {
          this.$set(this.lsitData, this.lsitData.length, item)
        })
      }
      if (records.length !== 10) {
        this.finished = true
      }
      this.loading = false
    },
    onLoad() {
      this.page++
      this.init()
    }
  }
}
</script>
  <style lang='scss' scoped>
  .container{
      box-sizing: border-box;
      // padding: 24px;
      background-color: #f6f6f6;
      padding-bottom: 200px;
      .content{
        margin: 0 24px;
        margin-top: 30px;
        padding-bottom: 20px;
        .tit{
          font-size: 30px;
          font-weight: 600;
        }
        .list{

          .li{
            display: flex;
            flex-direction: column;
            // justify-content: space-around;
            background-color: #fff;
            padding: 24px;
            margin-top: 24px;
            border-radius: 10px;
            .top{
                width: 100%;
                background-color: unset;
                justify-content: left;
                color: #000;
                padding: 0;
                margin: 0;
                font-size: 30px;

                // .types{
                //     color: #4A73FD;
                //     margin-right: 10px
                // }
            }
            .contents{
                margin-top: 30px;
                display: flex;
                align-items: center;
                // justify-content: space-between;
                // justify-content: center;

                .left{
                    display: flex;
                    align-items: center;
                    justify-content: center;
                    .userAvator{
                        width: 120px;
                        height: 120px;
                        border-radius: 5px;
                        margin-bottom: 5px
                    }
                }
                .right{
                    display: flex;
                    flex-direction: column;
                    // align-items: center;
                    // justify-content: center;
                    font-size: 30px;
                    margin-left: 20px;

                    .truename{
                        width: 500px;
                        white-space: nowrap;
                        overflow: hidden;
                        text-overflow: ellipsis;
                    }
                    .tags{
                        margin: 18px 0;
                        font-size: 26px;
                    }
                    .bots{
                        color:#ef3939;
                        display: flex;
                        align-items: baseline;
                        justify-content: flex-end;
                    }
                }

            }
            .time{
                margin-top: 20px;
            }
          }
        }
      }
  }

  </style>
